{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>首页新闻轮播</legend>
    </fieldset>
    <div class="demoTable">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item" >
                <label class="layui-form-label"><h3 style="color: #009688;font-size: 18px">新闻标题:</h3></label>
                <div class="layui-input-inline" >
                    <input class="layui-input" name="title" id="title" placeholder="{:lang('pleaseEnter')}新闻标题">
                </div>
                <button class="layui-btn" lay-submit=""  lay-filter="search" id="search" data-type="reload">搜索</button>
                <a onclick="javascript:window.location.reload();" class="layui-btn  layui-btn-warm"> 刷 新 </a>
            </div>
        </form>
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
</body>
{include file="common/foot"/}
<script type="text/html" id="barDemo">

    <a href="#" class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">{:lang('del')}</a>

</script>
<script type="text/html" id="create_time">
    <div>{{dateFormat(d.create_time)}}</div>
</script>
<script type="text/html" id="event_image">
    <img src="{{d.event_image}}" height="40px;" width="40px"
         onmouseover="layer.tips('<img   src={{d.event_image}}>',this,{tips: [1, '#fff'],area:'200px,200px'});"  onmouseout="layer.closeAll()">
</script>

<script type="text/html" id="topBtn">
    <a  class="layui-btn" lay-event="add">{:lang('add')}</a>
</script>

<script>
    var $;
    var page_current =0;
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, treeGrid = layui.treeGrid;$ = layui.jquery;
        var tableIn = table.render({
            elem: '#list',
            url: '{:url("lunboList")}',
            method:'post',
            toolbar: '#topBtn',
            title:'标准{:lang("list")}',
            page:true,
            cols: [[
                {field:'id', title: 'ID',align:"center", width:80,fixed: true}
                ,{field:'cate_name', align:"center",title: '新闻栏目', width:180}
                ,{field:'title', align:"center",title: '新闻标题', width:180}
                ,{field:'event_image', align:"center",title: '事件图片', width:180,templet:"#event_image"}
                ,{fixed:"right",width:200, align:'center',title:'操作',toolbar: '#barDemo'}
            ]],
            done:function(data,page,count){
                page_current = page;
            },
            limit:10,
        });

        $(document).keyup(function(event){
            if(event.keyCode ==13){
                $("#search").trigger("click");
            }
        });
        table.on('tool(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
                    $.post("{:url('lunboDel')}",{id:data.id},function(res){
                        if(res.code==0){
                            layer.msg(res.msg,{time:1000,icon:1});
                            window.location.reload();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });
        table.on('toolbar(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'add'){
                layer.open({
                    type: 2,
                    title: '新闻列表',
                    shade: 0.01,
                    shadeClose: true,
                    scrollbar: false,
                    area: ['80%', '80%'],
                    anim: 5,
                    content: "{:url('common/selectNews')}",
                    end:function (e) {
                        window.location.reload();
                    }
                });
            }
        });
        //搜索
        form.on("submit(search)",function (data) {
            tableIn.reload({ page: {curr: page_current},where: data.field});
            return false;
        });
    });
</script>
</html>